#include <stdio.h>

int main(){
  int m,n;
  int teste=1;
  while(scanf("%d %d\n", &m,&n)!=EOF && (m!=0 || n!=0)){
    char field[102][102];

    //initializing the borders
    for(int i=0;i<n+2;i++){
      field[0][i] = '.';
      field[m+1][i]='.';
    }
    for(int i=0;i<m+2;i++){
      field[i][0] = '.';
      field[i][n+1]='.';
    }

    //reading field
    for(int i=1;i<m+1;i++){
      for(int j=1;j<n+1;j++){
	scanf("%c", &field[i][j]);
      }
      scanf("\n");
    }

    if(teste!=1){
      printf("\n");
    }
    printf("Field #%d:\n", teste++);
    //counting bombs
    for(int i=1;i<m+1;i++){
      for(int j=1;j<n+1;j++){
	int bombs=0;
	if(field[i][j]=='*'){
	  printf("*");
	}else{
	  int sum = field[i-1][j-1]+field[i-1][j]+field[i-1][j+1]+
	    field[i][j-1]+field[i][j+1]+
	    field[i+1][j-1]+field[i+1][j]+field[i+1][j+1];
	  sum -= 8*'.';
	  
	  sum /=('*'-'.');
	  printf("%d", sum);
	}
      }
      printf("\n");
    }
  }
}
